import json
import os
from absl import flags
from coin.proto.coin_feed_subscriber_pb2 import FeedSubscriberConfig

flags.DEFINE_string('config', '', '')

flags.DEFINE_string('fs_config', None, '')


def get_fs_config():
  if flags.FLAGS.fs_config is not None:
    if os.path.exists(flags.FLAGS.fs_config):
      fs_config = open(flags.FLAGS.fs_config).read()
    else:
      fs_config = flags.FLAGS.fs_config
    print(fs_config)
    conf = json.loads(fs_config)
  else:
    conf = {'use_feed_arbitration': True, 'arbitration_connection_count': 2}
  return FeedSubscriberConfig(**conf)
